package com.koron.order.workbench.jobStatistics.controller;

import com.koron.bean.base.Response;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.workbench.jobStatistics.bean.query.JobStatisticsQuery;
import com.koron.order.workbench.jobStatistics.service.JobStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName JobStatisticsController
 * @description
 * @Author zhouj
 * @Date 2022/3/9 17:31
 */
@Api(tags = "工作统计(JobStatistics)")
@RestController
@RequestMapping("/JobStatistics/")
public class JobStatisticsController {

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @Autowired
    JobStatisticsService josbStatisticsService;

    @ApiOperation(value = "获取工作统计")
    @GetMapping("getJobStatistics")
    public Response<List> getJobStatistics(JobStatisticsQuery jobStatisticsQuery) {
        //获取待办列表
        return Response.ok(ADOConnection.runTask(getCurrDs(), josbStatisticsService, "getJobStatistics", List.class, jobStatisticsQuery));
    }

    @ApiOperation(value = "信息话平台建设系统-工单管理统计", notes = "消缺率eliminationRate，消缺及时率eliminationTimelyRate，当月缺陷数defectTotal")
    @GetMapping("orderFinishRate/gcxxh")
    public Response<Map<String,Object>> rateOfDefect(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
        Map<String,Object> result = ADOConnection.runTask("water_02", josbStatisticsService, "orderFinishRate", Map.class, startTime,endTime);
        return Response.ok(result);
    }

}
